package zbu.eb.run;
import zbu.eb.dao.AdminDaoImpl;
import zbu.eb.dao.EBikeDaoImpl;
import java.sql.SQLException;
import java.util.Scanner;

public class Run {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        AdminDaoImpl adminDao = new AdminDaoImpl();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String id = sc.nextLine();
        System.out.println("请输入密码：");
        String password = sc.nextLine();
        int flag = adminDao.login(id,password);
        if (flag == 1) {
            System.out.println("登录成功!!!");
            EBikeDaoImpl eb = new EBikeDaoImpl();
            while(true) {
                int choice = menu();
                switch (choice) {
                    case 0:
                        eb.exitSystem();
                        break;
                    case 1:
                        eb.addBike();
                        break;
                    case 2:
                        eb.delBike();
                        break;
                    case 3:
                        eb.showBike();
                        break;
                    case 4:
                        eb.findBike();
                        break;
                    case 5:
                        eb.alterBike();
                        break;
                    default:
                        System.out.println("输入非法！！！");
                        break;
                }
            }
        } else {
            System.out.println("登录失败!!!");
        }
    }
    public static int menu() {
        System.out.println("*****管理员界面*****");
        System.out.println("1.添加车辆");
        System.out.println("2.删除车辆");
        System.out.println("3.展示车辆");
        System.out.println("4.查找车辆");
        System.out.println("5.修改车辆");
        System.out.println("0.退出系统");
        System.out.println("***************");
        System.out.println("请输入你的操作：");
        Scanner sc = new Scanner(System.in);
        int choice = sc.nextInt();
        return choice;
    }
}
